package com.projeto.persistence;

import com.projeto.infra.business.GenericEntity;
import java.io.Serializable;
import javax.persistence.*;
import java.util.Date;
import java.util.Set;

/**
 * The persistent class for the shipment database table.
 *
 */
@Entity
public class Shipment extends GenericEntity implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    private String id;
    private String alias;
    private String awb;
    private int quantity;
    private double total;
    private float weight;
    private boolean inactive;
    @Temporal( TemporalType.TIMESTAMP)
    @Column(name = "CREATE_DT")
    private Date createDt;
    @Temporal( TemporalType.TIMESTAMP)
    @Column(name = "UPDATE_DT")
    private Date updateDt;
    //bi-directional many-to-one association to Usertable
    @ManyToOne
    @JoinColumn(name = "CREATED_BY")
    private User createdBy;
    //bi-directional many-to-one association to Usertable
    @ManyToOne
    @JoinColumn(name = "UPDATED_BY")
    private User updatedBy;
    //bi-directional many-to-one association to Receipt
    @OneToMany(mappedBy = "shipment")
    private Set<Receipt> receipts;
    //bi-directional many-to-one association to Customer
    @ManyToOne
    @JoinColumn(name = "SHIPPER")
    private Customer customer1;
    //bi-directional many-to-one association to Customer
    @ManyToOne
    @JoinColumn(name = "CONSIGNEE")
    private Customer customer2;
    //bi-directional many-to-one association to ShipmentDetail
    @OneToMany(mappedBy = "shipment")
    private Set<ShipmentDetail> shipmentDetails;

    public Shipment() {
    }

    @Override
    public String getId() {
        return this.id;
    }

    @Override
    public void setId(String id) {
        this.id = id;
    }

    public String getAlias() {
        return this.alias;
    }

    public void setAlias(String alias) {
        this.alias = alias;
    }

    public String getAwb() {
        return this.awb;
    }

    public void setAwb(String awb) {
        this.awb = awb;
    }

    public int getQuantity() {
        return this.quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    public double getTotal() {
        return this.total;
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public float getWeight() {
        return this.weight;
    }

    public void setWeight(float weight) {
        this.weight = weight;
    }

    public Set<Receipt> getReceipts() {
        return this.receipts;
    }

    public void setReceipts(Set<Receipt> receipts) {
        this.receipts = receipts;
    }

    public Customer getCustomer1() {
        return this.customer1;
    }

    public void setCustomer1(Customer customer1) {
        this.customer1 = customer1;
    }

    public Customer getCustomer2() {
        return this.customer2;
    }

    public void setCustomer2(Customer customer2) {
        this.customer2 = customer2;
    }

    public Set<ShipmentDetail> getShipmentDetails() {
        return this.shipmentDetails;
    }

    public void setShipmentDetails(Set<ShipmentDetail> shipmentDetails) {
        this.shipmentDetails = shipmentDetails;
    }

    @Override
    public Date getCreateDt() {
        return createDt;
    }

    @Override
    public void setCreateDt(Date createDt) {
        this.createDt = createDt;
    }

    @Override
    public Date getUpdateDt() {
        return updateDt;
    }

    @Override
    public void setUpdateDt(Date updateDt) {
        this.updateDt = updateDt;
    }

    @Override
    public User getCreatedBy() {
        return createdBy;
    }

    @Override
    public void setCreatedBy(User createdBy) {
        this.createdBy = createdBy;
    }

    @Override
    public User getUpdatedBy() {
        return updatedBy;
    }

    @Override
    public void setUpdatedBy(User updatedBy) {
        this.updatedBy = updatedBy;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 61 * hash + (this.id != null ? this.id.hashCode() : 0);
        hash = 61 * hash + (this.alias != null ? this.alias.hashCode() : 0);
        hash = 61 * hash + (this.awb != null ? this.awb.hashCode() : 0);
        hash = 61 * hash + this.quantity;
        hash = 61 * hash + (int) (Double.doubleToLongBits(this.total) ^ (Double.doubleToLongBits(this.total) >>> 32));
        hash = 61 * hash + Float.floatToIntBits(this.weight);
        hash = 61 * hash + (this.inactive ? 1 : 0);
        hash = 61 * hash + (this.createDt != null ? this.createDt.hashCode() : 0);
        hash = 61 * hash + (this.updateDt != null ? this.updateDt.hashCode() : 0);
        hash = 61 * hash + (this.createdBy != null ? this.createdBy.hashCode() : 0);
        hash = 61 * hash + (this.updatedBy != null ? this.updatedBy.hashCode() : 0);
        hash = 61 * hash + (this.receipts != null ? this.receipts.hashCode() : 0);
        hash = 61 * hash + (this.customer1 != null ? this.customer1.hashCode() : 0);
        hash = 61 * hash + (this.customer2 != null ? this.customer2.hashCode() : 0);
        hash = 61 * hash + (this.shipmentDetails != null ? this.shipmentDetails.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Shipment other = (Shipment) obj;
        if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
            return false;
        }
        if ((this.alias == null) ? (other.alias != null) : !this.alias.equals(other.alias)) {
            return false;
        }
        if ((this.awb == null) ? (other.awb != null) : !this.awb.equals(other.awb)) {
            return false;
        }
        if (this.quantity != other.quantity) {
            return false;
        }
        if (Double.doubleToLongBits(this.total) != Double.doubleToLongBits(other.total)) {
            return false;
        }
        if (Float.floatToIntBits(this.weight) != Float.floatToIntBits(other.weight)) {
            return false;
        }
        if (this.inactive != other.inactive) {
            return false;
        }
        if (this.createDt != other.createDt && (this.createDt == null || !this.createDt.equals(other.createDt))) {
            return false;
        }
        if (this.updateDt != other.updateDt && (this.updateDt == null || !this.updateDt.equals(other.updateDt))) {
            return false;
        }
        if (this.createdBy != other.createdBy && (this.createdBy == null || !this.createdBy.equals(other.createdBy))) {
            return false;
        }
        if (this.updatedBy != other.updatedBy && (this.updatedBy == null || !this.updatedBy.equals(other.updatedBy))) {
            return false;
        }
        if (this.receipts != other.receipts && (this.receipts == null || !this.receipts.equals(other.receipts))) {
            return false;
        }
        if (this.customer1 != other.customer1 && (this.customer1 == null || !this.customer1.equals(other.customer1))) {
            return false;
        }
        if (this.customer2 != other.customer2 && (this.customer2 == null || !this.customer2.equals(other.customer2))) {
            return false;
        }
        if (this.shipmentDetails != other.shipmentDetails && (this.shipmentDetails == null || !this.shipmentDetails.equals(other.shipmentDetails))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Shipment{" + "id=" + id + ", alias=" + alias + ", awb=" + awb + ", quantity=" + quantity + ", total=" + total + ", weight=" + weight + ", inactive=" + inactive + ", createDt=" + createDt + ", updateDt=" + updateDt + ", createdBy=" + createdBy + ", updatedBy=" + updatedBy + ", receipts=" + receipts + ", customer1=" + customer1 + ", customer2=" + customer2 + ", shipmentDetails=" + shipmentDetails + '}';
    }
}